<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>注册</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" media="screen" href="../../src/assets/css/main.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="../../src/assets/css/game.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="../css/common.css" />
    <script src="../script/jquery.min.js"></script>
    <script src="../script/common.js"></script>
    
    <style>
        *{
            box-sizing: initial;
            font-size: 14px;
        }
        html{
            height: 100%;
        }
        ul,li{
            margin: 0;
            padding: 0;
            list-style: none;
        }
        input:focus {
            outline: 0;
        }
        .table{
            width: 600px;
            margin: 300px auto 0;
        }
        .text-left{
            text-align: left;
            padding-left: 25px;
        }
        .btn_box{
            width: 260px;
            margin: 20px auto 0;
        }
        .btn_box>input{
            padding: 0px;
        }
        #codeImg{
            vertical-align: middle;
        }
        .wq{
            background-color: #E9BA84;
        }
        .t_list_caption{
            background: url(/static/images/bg.jpg);
            line-height: 24px;
            text-align: center;
            color: #000000;
            font-weight: bold;
        }
        .t_td_text{
            height: 27px;
            line-height: 17px;
            text-align: center;
            background-color: #FFFFFF;
        }
        .flexbox{
            display: -webkit-flex; /* Safari */
            display: flex;
        }
        .spacebetween{
            justify-content: space-between;
            align-items:center;
        }
        .operationbtn>input[type="button"],.operationbtn>input[type="reset"],.operationbtn>input[type="submit"]{
            width: 66px;
            height: 17px;
            border: none;
            background: url(/static/images/frame1.gif);
            background-position: -943px 0;
            cursor: pointer;
            color: #0c3e09;
            font-size: 12px;
        }
    </style>
</head>
<body>
    <div>
        <form method="post" enctype="application/x-www-form-urlencoded">
        <table class="wq text-center table" border="0" cellpadding="0" cellspacing="1">
            <tr class="t_list_caption">
                <td colspan="2">会员注册</td>
            </tr>
            <tr class="t_td_text">
                <td>会员账号：</td>
                <td class="text-left"><input type="text" id="account" /></td>
            </tr>
            <tr class="t_td_text">
                <td>登录密码：</td>
                <td class="text-left"><input type="text" id="pass" /></td>
            </tr>
            <tr class="t_td_text">
                <td>确认密码：</td>
                <td class="text-left"><input type="text" id="qrpass" /></td>
            </tr>
            <tr class="t_td_text">
                <td>验证码：</td>
                <td class="text-left"><input type="text" id="code" /><img class="code" alt="验证码" title="图片看不清？点击重新得到验证码" id="codeImg" onclick="getcode()" /></td>
            </tr>
            <tr>
                <td colspan="2"><label style="font-size: 12px;" for="agreen">*<input type="checkbox" checked id="agreen" style="vertical-align: middle;" />我已届满18岁合法博彩年龄，且同意各项开户条约。</label></td>
            </tr>
        </table>
        <div class="btn_box flexbox spacebetween operationbtn">
            <input type="button" value="立即注册" onclick="goRegister()" />
            <!-- <input type="button" value="重填" />
            <input type="button" value="返回首页" /> -->
        </div>
        </form>
        
    </div>
    <script>

        getyanzhengma();
        function getyanzhengma(){
            $('#codeImg').attr('src', commonUrl + "code");
        }
        
        //获取验证码
        function getcode(){

            $('#codeImg').attr('src', commonUrl + "code");
            
        }

        //注册
        function goRegister(){

            if($('#agreen').is(':checked')){
                if($('#account').val() == ''){
                    alert('请输入账号');
                    return;
                }
                if($('#pass').val() == ''){
                    alert('请输入登录密码');
                    return;
                }
                if($('#qrpass').val() == ''){
                    alert('请输入确认密码');
                    return;
                }
                if($('#code').val() == ''){
                    alert('请输入验证码');
                    return;
                }
                if($('#pass').val() != $('#qrpass').val() ){
                    alert('两次输入密码不一致');
                    return;
                }

                $.ajax({
                    type: "post",
                    url: commonUrl + "register",
                    data: {
                        name : $('#account').val(),
                        password : $('#pass').val(),
                        rePassword: $('#qrpass').val(),
                        code: $('#code').val()
                    },
                    dataType: "json",
                    success: function(data){
                        console.log(data);
                    },
                    error: function(error){
                        console.log(error);
                        // alert(error.response.data.msg);
                    }
                });
            }else{
                alert('请先同意各项开户条约');
            }
            
        }
    </script>
</body>
</html>